<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="org.apache.shiro.web.filter.authc.FormAuthenticationFilter"%>
<%@ page import="org.apache.shiro.authc.ExcessiveAttemptsException"%>
<%@ page import="org.apache.shiro.authc.IncorrectCredentialsException"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<meta charset="utf-8"/>
<title>后台管理系统:登录页</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<meta content="" name="description"/>
<meta content="" name="author"/>
<meta name="MobileOptimized" content="320">
<!-- BEGIN GLOBAL MANDATORY STYLES -->
<link href="${ctx}/static/metronic/assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
<link href="${ctx}/static/metronic/assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="${ctx}/static/metronic/assets/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css"/>
<!-- END GLOBAL MANDATORY STYLES -->
<!-- BEGIN THEME STYLES -->
<link href="${ctx}/static/metronic/assets/css/style-metronic.css" rel="stylesheet" type="text/css"/>
<link href="${ctx}/static/metronic/assets/css/style.css" rel="stylesheet" type="text/css"/>
<link href="${ctx}/static/metronic/assets/css/style-responsive.css" rel="stylesheet" type="text/css"/>
<link href="${ctx}/static/metronic/assets/css/plugins.css" rel="stylesheet" type="text/css"/>
<link href="${ctx}/static/metronic/assets/css/themes/default.css" rel="stylesheet" type="text/css" id="style_color"/>
<link href="${ctx}/static/metronic/assets/css/pages/login.css" rel="stylesheet" type="text/css"/>
<link href="${ctx}/static/metronic/assets/css/custom.css" rel="stylesheet" type="text/css"/>
<!-- END THEME STYLES -->
<link rel="shortcut icon" href="${ctx}/static/images/favicon.ico"/>
</head>
<!-- BEGIN BODY -->
<body class="login">
<!-- BEGIN LOGO -->
<div class="logo">
	<img src="${ctx}/static/metronic/assets/img/logo-big.png" alt=""/>
</div>
<!-- END LOGO -->
<!-- BEGIN LOGIN -->
<div class="content">
	<!-- BEGIN LOGIN FORM -->
	<form id="loginForm" class="login-form" action="${ctx}/login" method="post">
		<h3 class="form-title">登陆系统</h3>
		<div class="alert alert-danger display-hide">
			<button class="close" data-close="alert"></button>
			<span>
				 Enter any username and password.
			</span>
		</div>
		<div class="form-group">
			<!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
			<label class="control-label visible-ie8 visible-ie9">用户名</label>
			<div class="input-icon">
				<i class="fa fa-user"></i>
				<input class="form-control placeholder-no-fix required" type="text" autocomplete="off" placeholder="用户名" name="username" value="${username}"/>
			</div>
		</div>
		<div class="form-group">
			<label class="control-label visible-ie8 visible-ie9">密码</label>
			<div class="input-icon">
				<i class="fa fa-lock"></i>
				<input class="form-control placeholder-no-fix required" type="password" autocomplete="off" placeholder="密码" name="password"/>
			</div>
		</div>
		<div class="form-group">
			<label class="control-label visible-ie8 visible-ie9">验证码</label>
			<div class="input-icon">
				<i class="fa fa-asterisk"></i>
				<input class="form-control placeholder-no-fix required" type="text" autocomplete="off" placeholder="验证码" name="captcha"/>
			</div>
		</div>
		<div class="form-group">
			<img title="点击更换" id="captchaImg" onclick="javascript:refreshCaptcha();"
				src="about:blank">(看不清<a href="javascript:void(0)" onclick="javascript:refreshCaptcha()">换一张</a>)
			<label class="checkbox" style="float:right"><input type="checkbox" id="rememberMe" name="rememberMe"/>记住密码</label>
		</div>
		<div class="form-actions">
			<button type="submit" class="btn green pull-right">
			Login <i class="m-icon-swapright m-icon-white"></i>
			</button>
		</div>
	</form>
	<!-- END LOGIN FORM -->

</div>
<!-- END LOGIN -->
<!-- BEGIN COPYRIGHT -->
<div class="copyright">
	 2007-2014. 通睿享络digitalnet
</div>
<!-- END COPYRIGHT -->
<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
<!-- BEGIN CORE PLUGINS -->
<!--[if lt IE 9]>
	<script src="${ctx}/static/metronic/assets/plugins/respond.min.js"></script>
	<script src="${ctx}/static/metronic/assets/plugins/excanvas.min.js"></script> 
	<![endif]-->
<script src="${ctx}/static/metronic/assets/plugins/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="${ctx}/static/metronic/assets/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="${ctx}/static/metronic/assets/plugins/uniform/jquery.uniform.min.js" type="text/javascript"></script>
<!-- END CORE PLUGINS -->
<!-- BEGIN PAGE LEVEL PLUGINS -->
<script src="${ctx}/static/metronic/assets/plugins/jquery-validation/dist/jquery.validate.min.js" type="text/javascript"></script>
<script src="${ctx}/static/metronic/assets/plugins/jquery-validation/localization/messages_zh.js" type="text/javascript"></script>
<!-- END PAGE LEVEL PLUGINS -->
<script>
	function initCheckbox(){
        if (!jQuery().uniform) {
            return;
        }
        var test = $("input[type=checkbox]:not(.toggle), input[type=radio]:not(.toggle, .star)");
        if (test.size() > 0) {
            test.each(function () {
                if ($(this).parents(".checker").size() == 0) {
                    $(this).show();
                    $(this).uniform();
                }
            });
        }
	}
	$(document).ready(function() {
		initCheckbox();
		refreshCaptcha();
		$("#loginForm").validate({
            errorElement: 'span', //default input error message container
            errorClass: 'help-block', // default input error message class
            focusInvalid: false, // do not focus the last invalid input
            ignore: ".ignore",
		
            highlight: function (element) { // hightlight error inputs
                $(element).closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group   
            },

            unhighlight: function (element) { // revert the change done by hightlight
                $(element).closest('.form-group').removeClass('has-error').addClass('has-success'); // set success class to the control group
            },

            success: function (label, element) {
                $(element).closest('.form-group').removeClass('has-error').addClass('has-success'); // set success class to the control group
            },
            
			rules:{
				captcha : {
					remote : "${ctx}/login/checkCaptcha"
				}
			},
			
			messages:{
				captcha : {
					remote : "验证码错误"
				}
			}
		});
	});
	var _captcha_id = "#captchaImg";
	function refreshCaptcha() {
		$(_captcha_id).attr("src","servlet/captchaCode?t=" + Math.random());
	}
</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>